package designpattern.singleton.type3;

/*
    懒汉式(线程不安全)
 */
public class Singleton {
    public static Singleton singleton;

    private Singleton(){

    }

    public static Singleton getInstance(){
        if(singleton==null){
            singleton = new Singleton();
        }
        return singleton;
    }
}
class Test{
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                System.out.println(Singleton.getInstance());
            }).start();
        }
    }
}
